<template>
  <div>
    <div class="wrap">
      <!-- 渠道分布以及季度销售模块 -->
      <div class="channel panel">
        <div class="inner">
          <h3>渠道分布</h3>
          <div class="data">
            <div class="item">
              <h4>
                39
                <small>%</small>
              </h4>
              <span class="airplan"></span>
              机场
            </div>
            <div class="item">
              <h4>
                28
                <small>%</small>
              </h4>
              <span class="shopping"></span>
              商场
            </div>
          </div>
          <div class="data">
            <div class="item">
              <h4>
                20
                <small>%</small>
              </h4>
              <span class="ditie"></span>
              地铁
            </div>
            <div class="item">
              <h4>
                13
                <small>%</small>
              </h4>
              <span class="huochezhan"></span>
              火车站
            </div>
          </div>
        </div>
      </div>
      <!-- 销售进度模块 -->
      <div class="quarter panel">
        <div class="inner">
          <h3>一季度销售进度</h3>
          <div class="chart">
            <div class="box">
              <div class="gauge" ref="gauge"></div>
            </div>
            <div class="data">
              <div class="item">
                <h4>1,321</h4>
                <span>
                  <i class="icon-dot" style="background-color: #6acca3"></i>
                  销售额(万元)
                </span>
              </div>
              <div class="item">
                <h4>   150%</h4>
                <span>
                  <i class="icon-dot" style="background-color: #ed3f35"></i>
                  同比增长
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import echarts from 'echarts'
export default {
  mounted(){
    // 仪表盘
    let chart = this.$echarts.init(this.$refs.gauge)
    chart.setOption({
      series: [
        {
          type: "gauge",
          center: ["40%", "80%"],  // 位置
          radius: "160%",  // 半径
          startAngle: 185,  // 开始角度
          endAngle: 0,  // 结束角度
          min: 0,  // 仪表盘最大值
          max: 100,  // 仪表盘最小值
          z: 5,  // 前后顺序
          // 仪表盘指针样式
          itemStyle: {
            color: new this.$echarts.graphic.LinearGradient(
                // (x1,y2) 点到点 (x2,y2) 之间进行渐变
                0,
                0,
                0,
                1,
                [
                    {offset: 0, color: "#00fffb"}, // 0 起始颜色
                    {offset: 1, color: "#0061ce"} // 1 结束颜色
                ]
            ),

          },
          // 展示当前进度
          progress: {
            show: true,
            width: 7
          },
          // 仪表盘指针
          pointer: {
            show: false
          },
          // 仪表盘背景
          axisLine: {
            show: true,
            lineStyle: {
              width: 7,
            }
          },
          // 刻度样式
          axisTick: {
            show: false,
          },
          // 分隔线样式
          splitLine: {
            show: false,
          },
          // 刻度标签
          axisLabel: {
            show: false,
          },
          // 表盘中指针的固定点
          anchor: {
            show: false
          },
          // 标题
          title: {
            show: false
          },
          // 仪表盘详情，用于显示数据
          detail: {
            valueAnimation: true,
            width: "60%",
            fontWeight:'normal',
            lineHeight: 40,
            borderRadius: 8,
            offsetCenter: [0, "2%"],
            fontSize: 20,
            formatter: "{value} %",
            color: "#fff",
          },
          data: [75]
        },
      ]
    })
  }
};
</script>

<style scoped>
/* 渠道分布以及季度销售模块 */
.wrap {
  display: flex;
}
.channel,.quarter{
  flex:1;
  height: 3.6rem;
}
.channel{
  margin-right: 0.25rem;
}
.channel h3{
  font-size: 0.35rem;
}
.channel .data{
  width: 3.3rem;
  height: 1.3rem;
}

.channel h4{
  color: #fff;
  font-size: 0.45rem;
  margin-bottom: 0.0625rem;
  font-weight: 450;
}
.channel span{
  display: inline-block;
  width: 15px;
  height: 15px;
}
.channel .item{
  display: inline-block;
  font-size: 0.03rem;
  color: #4c9bfd;
  margin-top: 0.15rem;
  margin-left: 1.25rem;
}
.item:first-child{
  margin-left: 0.15rem;
}
.airplan{
  background: url(../../assets/image/机场.png) center bottom no-repeat;
  background-size: 25px auto;
}
.shopping{
  background: url(../../assets/image/商场.png) center bottom no-repeat;
  background-size: 13px auto;
}
.ditie{
  background: url(../../assets/image/地铁.png) center bottom no-repeat;
  background-size: 13px auto;
}
.huochezhan{
  background: url(../../assets/image/火车站.png) center bottom no-repeat;
  background-size: 13px auto;
}
.channel small{
  font-size: 50%;
}
/* 季度 */
.quarter .inner{
  display: flex;
  flex-direction: column;
  margin: 0 -0.075rem;
}
.quarter .chart{
  flex: 1;
  padding-top: 0.225rem;
}
.quarter .box{
  position: relative;
}

.quarter .gauge{
  height: 1.05rem;
}

.quarter .data{
  display: flex;
  justify-content: space-between;
}

.quarter .item{
  width: 50%;
}

.quarter h4{
  color:#fff;
  font-size: 0.4rem;
  margin-bottom: 0.125rem;
  font-weight: 450;
  
}

.quarter span{
  display: block;
  width: 100%;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  color: #4c9bfd;
  font-size: 0.2rem;
}

.quarter h3{
  font-size: 0.35rem;
}

/* 图标 */
.icon-dot{
    display: inline-block;
    width: 4.5px;
    height: 9px;
    border-radius: 4px;
  }
</style>